﻿@{
    ViewBag.Title = "AccountList";
}

<div id="cphMain_ctl00_ContentPane" class="center">
    <div id="Breadcrumb" class="Breadcrumb">
        <ul>
            <li class="first">
                <a href='javascript:;' onclick="javascript:loadAction('Index2','Main')">Trang chủ
                </a>
            </li>
            <li>
                <a href='javascript:;' onclick="javascript:loadAction('personal','Account')">Tài khoản của tôi
                </a>
            </li>
            <li>
                <span>Danh sách tài khoản</span>
            </li>
        </ul>
    </div>

    <div class="Account-Module DefaultModule">

        <div class="Block DefaultModule">


            <div id="CartHeader" class="Block Moveable Panel">
                <h2>Danh sách tài khoản
                </h2>
            </div>

            <div id="CartContainer" class="Block Moveable Panel">

                <div class="BlockContent">
                    @if (ViewBag.accList != null)
                    {                
                        <div class="Clear">
                            <div class="FloatRight">
                                <a href="javascript:;" onclick="javascrip:loadAction('AccountDetail','Admin')"
                                    class="myBtn1">Thêm tài khoản mới</a>
                            </div>
                        </div>

                        <div class="Clear">
                        </div>

                        <div>
                            <div>

                                <table class="CartContents" cellspacing="0" rules="rows" border="1"
                                    id="cphMain_ctl00_ctl01_ctl00_grvList" style="width: 100%; border-collapse: collapse;">
                                    <tbody>
                                        <tr class="even-row">
                                            <th scope="col" style="text-align: left">Tên tài khoản
                                            </th>
                                            <th scope="col" style="text-align: left">Tên đầy đủ
                                            </th>

                                            <th scope="col" style="text-align: left">Số điện thoại
                                            </th>
                                            <th scope="col" style="text-align: left">Cấp bậc
                                            </th>
                                            <th scope="col">&nbsp;</th>
                                        </tr>
                                        @{var rowCount = 0; string cssRowClass = "";}
                                        @foreach (var acc in ViewBag.accList)
                                        {
                                            if (++rowCount % 2 == 1) { cssRowClass = "old-row"; }
                                            else { cssRowClass = "even-row"; }
                                            <tr class="@cssRowClass">
                                                <td>
                                                    <a href="javascript:;" onclick="javascript:viewAccountDetail(@acc.ID)">
                                                        <strong>@acc.username</strong></a>
                                                    <br>
                                                </td>
                                                <td>
                                                    @acc.full_name
                                                </td>
                                                <td style="width: 100px;">
                                                    <span>@acc.phone_number</span>
                                                </td>
                                                <td style="width: 100px;">
                                                    @{var level = new string[] { "Quản trị", "Nhân viên", "Khách hàng", "Chờ kích hoạt", "Bị Khóa" };}
                                                    <span>@level[acc.user_level]</span>
                                                </td>
                                                <td style="width: 1px;">
                                                    <a href="javascript:;" onclick="javascript:deleteAccount(@acc.ID)" class="myBtn1">Xóa</a>
                                                </td>
                                            </tr>
                                        }
                                    </tbody>
                                </table>
                            </div>
                        </div>                                    
                    }
                </div>

                                            <div class="PageNavigation" style="padding-bottom: 10px; padding-top: 10px;" align="center">
            @{var previousPage = Math.Max(ViewBag.currentPage-1, 1);}
            <a  href="javascript:;" onclick="javascript:loadActionData('AccountList','Admin','pageNum=@previousPage')">&lt;&lt;</a>    
            @for(int num = 1; num <= ViewBag.maxPage; num ++)
            {
               if(ViewBag.currentPage == num)
               {
                  <a class="active" href="#" 
                      style="background-color:gray;color:white;"><strong>@num</strong></a>
                }
                else
                {
                   <a  href="javascript:;" onclick="javascript:loadActionData('AccountList','Admin','pageNum=@num')">@num</a>    
                }
            }                   
            @{var nextPage = Math.Min(ViewBag.maxPage, ViewBag.currentPage + 1);}
            <a href="javascript:;" onclick="javascript:loadActionData('AccountList','Admin','pageNum=@nextPage')">&gt;&gt;</a>    
        </div>

            </div>
        </div>
    </div>
</div>
